<div class="box">
    <h2>
        <a id="toggle-articles" href="#" style="background-color:#006633;" class="hidden"><?php echo _('Date')?></a>
    </h2>
    <div id="articles" style="display: none;">
        <div class=" block date_selector">
            <p>
                <label> Go to date:</label>
                <input id="current_date" type="text" class="date" value="<?php echo $date?>" />
                <input class="submit" type="button" value="Go" />
            </p>
        </div>

        <script language="JavaScript" type="text/javascript">
            $("#current_date").datepicker({dateFormat: 'yy-mm-dd'});
            $('.date_selector .submit').click(function(){
                var date = $("#current_date").val();
                if (/[0-9]{4}-[0-9]{2}-[0-9]{2}/.test(date)) {
                    parseCallingURL(window.location);
                    var url =  window.location.protocol + '//' + window.location.hostname;
                    var name, value;
                    var names = getNameArray();
                    var values = getValueArray();
                    var cnt = 0;
        //            for (i in names) {
        //                name = names[i];
        //                value = values[i];
        //                if (name == 'year' || name == 'month' || name == 'day' || name == 'phone') {
        //                    continue;
        //                }
        //                url += (cnt > 0 ? '&' : '?');
        //                url += name + '=' + encodeURI(value);
        //                cnt++;
        //            }
                    date = new Date(date);
                    var now = new Date();
                    var dateArray = {};
                    if (now.getDate() != date.getDate()) {
                        dateArray['day'] = date.getDate();
                    }
                    if (now.getMonth() != date.getMonth()) {
                        dateArray['month'] = date.getMonth() + 1;
                    }
                    if (now.getFullYear() != date.getFullYear()) {
                        dateArray['year'] = date.getFullYear();
                    }
                    for (i in dateArray) {
                        name = i;
                        value = dateArray[i];
                        url += (cnt > 0 ? '&' : '?');
                        url += name + '=' + encodeURI(value);
                        cnt++;
                    }
                    window.location = url;
                }
            });
        </script>
    </div>
</div>
